//
//  ViewController.swift
//  加载中
//
//  Created by YYY on 2017/8/21.
//  Copyright © 2017年 成品家（北京）网路科技有限公司. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    //自定义刷新控件，最重要解决的是：用户放手之后，再进行刷新。
    
    lazy var refreshControl: CPJRefreshControl = CPJRefreshControl()
    
    @IBOutlet weak var myTableView: UITableView!
    
    //计算型属性
    var titleStr: String{
        return "Mr" + "Zhang"
    }
    
    func test(){
        let name = titleStr
        print(name)
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        test()
        
        //添加刷新控件
        myTableView.contentInset = UIEdgeInsetsMake(64, 0, 0, 0)
        myTableView.addSubview(refreshControl)
        refreshControl.addTarget(self, action: #selector(loadData), for: .valueChanged)
        loadData()
        
        
        // Do any additional setup after loading the view, typically from a nib.
    }
    
    @objc func loadData()
    {
        refreshControl.beginRefreshing()
        let interval = DispatchTime.now() + 3
        
        DispatchQueue.main.asyncAfter(deadline: interval)
        {
            //结束刷新
            self.refreshControl.endRefreshing()
        }
    }
    
    

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

